home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / cwtrial / disk1 / 32sinst.mst < prev    next >
Text File  |  1994-11-16  |  12KB  |  410 lines

  1. '**************************************************************************
  2. '*                  MS Test script for Win32s setup program
  3. '**************************************************************************
  4.  
  5. '' $DEFINE DEBUG  ''Define for script development/debugging
  6.  
  7. '$INCLUDE 'setupapi.inc'
  8. '$INCLUDE 'msdetect.inc'
  9.  
  10. ''Dialog ID's
  11. CONST WELCOME                  = 100
  12. CONST ASKQUIT                  = 200
  13. CONST DESTPATH                 = 300
  14. CONST EXITFAILURE              = 400
  15. CONST EXITQUIT                 = 600
  16. CONST EXITSUCCESS              = 700
  17. CONST OPTIONS                  = 800
  18. CONST BADPATH                  = 6400
  19.  
  20. CONST HELPWELCOME              = 1000
  21. CONST VERPATH                  = 1100
  22. CONST EXITFAILNOTWIN31         = 1200
  23. CONST EXITFAILNOTENH           = 1300
  24. CONST EXITFAILNOTPAGING        = 1325
  25. CONST EXITFAILNOTINTEL         = 1350
  26. CONST FREECELLINST             = 1400
  27. CONST FREECELLINSTNOWIN32S     = 1450
  28. CONST FREECELLPATH             = 1500
  29. CONST HELPFREECELL             = 1600
  30.  
  31.  
  32. ''Bitmap ID
  33. CONST LOGO = 1
  34.  
  35. GLOBAL DESTSYS$      ''Windows\System directory.
  36. GLOBAL DEST32S$      ''Windows\System\Win32s directory
  37. GLOBAL DESTFREE$     ''Freecell directory
  38.  
  39. GLOBAL DESTWIN$      '' Windows Directory - ClarisInstaller
  40. GLOBAL RUNBUF$       '' Run= buffer - ClarisInstaller
  41. GLOBAL WIN32ENABLED%
  42. GLOBAL WINDIR$  
  43.  
  44. DECLARE SUB Install
  45. DECLARE SUB UpdateSystemIni
  46. DECLARE SUB RebootSystem
  47. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  48. DECLARE FUNCTION MakeSystemIni LIB "INIUPD.DLL" (arg1$, arg2$) AS INTEGER
  49. DECLARE FUNCTION RestartWindows LIB "INIUPD.DLL" AS INTEGER
  50. DECLARE FUNCTION OnWindowsNT LIB "INIUPD.DLL" AS INTEGER
  51. DECLARE FUNCTION PagingEnabled LIB "INIUPD.DLL" AS INTEGER
  52. DECLARE FUNCTION ShareEnabled LIB "INIUPD.DLL" AS INTEGER
  53. DECLARE FUNCTION IsWin32sLoaded LIB "INIUPD.DLL" (arg1$) AS INTEGER
  54. DECLARE FUNCTION ExitWindowsExec LIB "USER.EXE" (arg1$, arg2$) AS INTEGER
  55.  
  56. INIT:
  57.     CUIDLL$ = "mscuistf.dll"            ''Custom user interface dll
  58.     HELPPROC$ = "FHelpDlgProc"        ''Help dialog procedure
  59.     szOldVer$ ="1.00.000     "        ''Reserve space in string for version
  60.     WIN32ENABLED% = 0
  61.  
  62.     ON ERROR GOTO ERRNORMAL
  63.  
  64.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  65.  
  66.     SetBitmap CUIDLL$, LOGO
  67.     
  68.     '' claris
  69.     SetTitle "Microsoft Win32s / ClarisWorks 3.0 Trial Setup Program"
  70.  
  71.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  72.     IF szInf$ = "" THEN
  73.     szInf$ = GetSymbolValue("STF_CWDDIR") + "32sinst.inf"
  74.     END IF
  75.     ReadInfFile szInf$
  76.  
  77.     DESTSYS$ = GetWindowsSysDir()
  78.     DEST32S$ = DESTSYS + "WIN32S\"
  79.  
  80. CHECK:
  81.     IF GetWindowsMajorVersion < 3 THEN
  82.     ExitCode% = EXITFAILNOTWIN31
  83.     GOTO QUIT
  84.     END IF
  85.     
  86.     IF GetWindowsMajorVersion = 3 AND GetWindowsMinorVersion < 1 THEN
  87.     ExitCode% = EXITFAILNOTWIN31
  88.     GOTO QUIT
  89.     END IF
  90.     
  91.     IF GetWindowsMajorVersion >= 4 THEN
  92.     ExitCode% = EXITSUCCESS
  93.     WIN32ENABLED% = 1
  94.     GOTO COPYFILES
  95.     END IF
  96.     
  97.     IF GetWindowsMode < 2  THEN
  98.     IF OnWindowsNT() THEN
  99.        ExitCode% = EXITFAILNOTINTEL    '' Running on Windows NT (on RISC)
  100.     ELSE
  101.        ExitCode% = EXITFAILNOTENH    '' Standard Mode Windows
  102.     END IF
  103.     
  104.     GOTO QUIT
  105.     END IF
  106.     
  107.     IF OnWindowsNT() THEN
  108.     ExitCode% = EXITSUCCESS
  109.     WIN32ENABLED% = 1
  110.     GOTO COPYFILES
  111.     END IF
  112.     
  113.     ExitCode% = EXITSUCCESS
  114.  
  115.  
  116.     '' Get version of Win32s to be installed from version info in file
  117.     szNewVer$ = GetVersionOfFile( GetSymbolValue("STF_SRCDIR") + "WIN32S16.DLL" )
  118.  
  119.     '' Check if Win32s is partially installed
  120.     sz$ = GetIniKeyString (DESTSYS$ + "WIN32S.INI", "Win32s", "Setup")
  121.     '' If WIN32S.INI specifies Setup=0, then force complete Win32s file overwrite
  122.     IF sz$ = "0" THEN
  123.     GOTO WELCOME
  124.     END IF
  125.     '' If WIN32S.INI is missing, try and reinstall Win32s files/recreate WIN32S.INI
  126.     IF sz$ <> "1" THEN
  127.     GOTO WELCOME
  128.     END IF
  129.  
  130.     '' If Win32s is already installed, get running version number
  131.     i% = DoesFileExist( DESTSYS$ + "W32SYS.DLL", femExists )
  132.     IF i% = 1 THEN
  133.     i% = IsWin32sLoaded( szOldVer$ )
  134.     ENDIF
  135.  
  136.     IF i% = 0 THEN
  137.     GOTO WELCOME
  138.     END IF
  139.     
  140.     IF szNewVer$ > szOldVer$ THEN
  141.     GOTO WELCOME
  142.     END IF
  143.     
  144.     WIN32ENABLED% = 1
  145.     
  146.     GOTO COPYFILES
  147.  
  148.  
  149. WELCOME:
  150.     sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", HELPWELCOME, HELPPROC$)
  151.     IF sz$ = "CONTINUE" THEN
  152.     UIPop 1
  153.     ELSE
  154.     GOSUB ASKQUIT
  155.     GOTO WELCOME
  156.     END IF
  157.  
  158.  
  159. GETWIN32SPATH:
  160.     IF PagingEnabled() = 0 THEN
  161.     i% = DoMsgBox("Use the Control Panel 386 Enhanced icon and configure Windows using the Virtual Memory option.", "Win32s requires Virtual Memory", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  162.     ExitCode% = EXITFAILURE '' Enhanced mode but not paging
  163.     GOTO QUIT
  164.     END IF
  165.  
  166.     ''IF ShareEnabled() = 0 THEN
  167.     ''i% = DoMsgBox( "File-sharing must be enabled. Run SHARE.EXE before starting Windows or add SHARE.EXE to your AUTOEXEC.BAT file.", "Win32s Setup: SHARE.EXE is not loaded", MB_TASKMODAL+MB_ICONEXCLAMATION+MB_OK)
  168.     ''END IF
  169.  
  170.     SetSymbolValue "EditTextIn", DESTSYS$
  171.     SetSymbolValue "EditFocus", "END"
  172.  
  173. GETPATHL1:
  174.     sz$ = UIStartDlg(CUIDLL$, VERPATH, "FDispDlgProc", HELPWELCOME, HELPPROC$)
  175.  
  176.     IF sz$ = "CONTINUE" THEN
  177.     IF IsDirWritable(DESTSYS$) = 0 THEN
  178.         GOSUB BADPATH
  179.         GOTO GETPATHL1
  180.     END IF
  181.     UIPop 1
  182.     ELSEIF sz$ = "REACTIVATE" THEN
  183.     GOTO GETPATHL1
  184.     ELSEIF sz$ = "BACK" THEN
  185.     UIPop 1
  186.     GOTO WELCOME
  187.     ELSE
  188.     GOSUB ASKQUIT
  189.     GOTO GETPATHL1
  190.     END IF
  191.  
  192.  
  193. COPYFILES:
  194.     
  195.     IF WIN32ENABLED% <> 1 THEN
  196.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "0", cmoOverwrite
  197.     END IF
  198.     
  199.     '' Indicate Win32s install failure until all files known to be copied.
  200.     
  201.     ExitCode% = EXITFAILURE
  202.     
  203.     ERR = 0
  204.  
  205.     
  206.     IF WIN32ENABLED% <> 1 THEN
  207.     CreateDir DEST32S$, cmoNone
  208.     END IF
  209.  
  210.     
  211.     Install
  212.     
  213.     '' Terminate if unhandled fatal error
  214.     IF ERR <> 0 THEN
  215.     GOTO QUIT
  216.     END IF
  217.     
  218.     IF WIN32ENABLED% <> 1 THEN
  219.     UpdateSystemIni
  220.     END IF
  221.  
  222.     IF WIN32ENABLED% <> 1 THEN
  223.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "1", cmoOverwrite
  224.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Version", szNewVer$, cmoOverwrite
  225.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Nls", "AnsiCP", "1252", cmoOverwrite
  226.     END IF
  227.  
  228.  
  229.     ERR = 0
  230.     CreateProgmanGroup "CW3TRIAL", "", cmoNone
  231.     ShowProgmanGroup   "CW3TRIAL", 1, cmoNone
  232.     CreateProgmanItem  "CW3TRIAL", "ClarisWorks 3.0 Trial", "C:\CW3TRIAL\CLWORKS.EXE", "", cmoOverwrite
  233.     CreateProgmanItem  "CW3TRIAL", "Begin Here", "C:\CW3TRIAL\CLWORKS.EXE C:\CW3TRIAL\BEGIN.CWK", "C:\CW3TRIAL\CLWORKS.EXE, 1", cmoOverwrite
  234.  
  235.     WINDIR$ = GetWindowsDir()
  236.     CreateIniKeyValue WINDIR$ + "CW3TRIAL.INI", "Claris", "Claris Directory", "C:\CW3TRIAL\CLARIS",cmoOverwrite
  237.     
  238.     i% = DoMsgBox("Win32s / ClarisWorks 3.0 Trial successfully installed.", "Microsoft Win32s Setup", MB_OK+MB_TASKMODAL)
  239.     
  240.     '' Indicate Win32s correctly copied and installed.
  241.     ExitCode% = EXITSUCCESS
  242.     
  243.  
  244.  
  245. QUIT:
  246.     '' Install error handler for final message box routines
  247.     ON ERROR GOTO ERRQUIT
  248.     IF ERR = 0 THEN
  249.     dlg% = ExitCode%
  250.     ELSEIF ERR = STFQUIT THEN
  251.     dlg% = EXITQUIT
  252.     ExitCode% = EXITQUIT
  253.     ELSE
  254.     dlg% = EXITFAILURE
  255.     ExitCode% = EXITQUIT
  256.     END IF
  257.  
  258. QUITL1:
  259.     IF WIN32ENABLED% = 1 THEN
  260.     UIPop 1
  261.     END
  262.     END IF
  263.  
  264.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  265.     IF sz$ = "REACTIVATE" THEN
  266.     GOTO QUITL1
  267.     END IF
  268.     UIPop 1
  269.  
  270.     IF ExitCode% = EXITSUCCESS THEN
  271.     RebootSystem
  272.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "0", cmoOverwrite
  273.     i% = DoMsgBox("Win32s is not properly configured and Win32s Setup must be run again.", "Unable to Restart Windows", MB_ICONEXCLAMATION+MB_OK+MB_TASKMODAL)
  274.     ENDIF
  275.  
  276.     END
  277.  
  278. '' Fatal error handler for error message routine
  279. ERRQUIT:
  280.     i% = DoMsgBox("Setup sources were corrupted!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  281.     END
  282.  
  283. '' Bypass run-time errors. Let final dialog box display fatal error message.
  284. ERRNORMAL:
  285.     '' Check if user cancelled setup
  286.     IF ERR = STFQUIT THEN
  287.     GOTO QUIT
  288.     END IF
  289.     RESUME NEXT
  290.  
  291.  
  292. BADPATH:
  293.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  294.     IF sz$ = "REACTIVATE" THEN
  295.     GOTO BADPATH
  296.     END IF
  297.     UIPop 1
  298.     RETURN
  299.  
  300.   ASKQUIT:
  301.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  302.  
  303.     IF sz$ = "EXIT" THEN
  304.     UIPopAll
  305.     ERROR STFQUIT
  306.     ELSEIF sz$ = "REACTIVATE" THEN
  307.     GOTO ASKQUIT
  308.     ELSE
  309.     UIPop 1
  310.     END IF
  311.     RETURN
  312.  
  313.  
  314.  
  315. '**
  316. '** Purpose:
  317. '**     Builds the copy list and performs all installation operations.
  318. '** Arguments:
  319. '**     none.
  320. '** Returns:
  321. '**     none.
  322. '*************************************************************************
  323. SUB Install STATIC
  324.  
  325.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  326.  
  327.     IF WIN32ENABLED% <> 1 THEN
  328.     
  329.     '' Use file layout sections that specify OLDER file version/time check
  330.     AddSectionFilesToCopyList "WindowsSystem", SrcDir$, DESTSYS$
  331.     AddSectionFilesToCopyList "WindowsSystemWin32s", SrcDir$, DESTSYS$ + "WIN32S\"
  332.  
  333.     '' Add obsolete files to be removed
  334.     AddSectionFilesToCopyList "Win32sSystemObsoleteFiles", SrcDir$, DESTSYS$ + "WIN32S\"
  335.  
  336.     SetRestartDir GetWindowsDir()
  337.     
  338.     END IF
  339.  
  340.     DESTWIN$ = "C:\CW3TRIAL"
  341.     CreateDir DESTWIN$, cmoNone
  342.     AddSectionFilesToCopyList "CW3Trial1", SrcDir$, DESTWIN$
  343.  
  344.     DESTWIN$ = "C:\CW3TRIAL\CLARIS"
  345.     CreateDir DESTWIN$, cmoNone
  346.     AddSectionFilesToCopyList "CW3Trial2", SrcDir$, DESTWIN$
  347.     
  348.     DESTWIN$ = "C:\CW3TRIAL\CLARIS\ASSISTNT"
  349.     CreateDir DESTWIN$, cmoNone
  350.     AddSectionFilesToCopyList "CW3Trial3", SrcDir$, DESTWIN$
  351.     '' Claris
  352.  
  353.     CopyFilesInCopyList
  354.  
  355. END SUB
  356.  
  357.  
  358. SUB UpdateSystemIni STATIC
  359.  
  360.     VxDPath$ = DEST32S$ + "W32S.386"
  361.     SystemIniPath$ = GetWindowsDir()
  362.  
  363.     t% = MakeSystemIni(SystemIniPath$, VxdPath$)
  364.  
  365. END SUB
  366.  
  367. SUB RebootSystem STATIC
  368.  
  369. '   Check if any files were locked during install.  If the RestartList
  370. '   is not empty, ExitExecRestart() will restart Windows, cleanup setup
  371. '   files, and copy over locked files before Windows restarts.
  372.     i% = RestartListEmpty()
  373.     IF i% = 0 THEN
  374. '      ExitExecRestart() only returns if applications refuse to be shutdown.
  375. '      Win32s is installed but will not operate until Windows is restarted
  376. '      and the Win32s VxD is loaded.
  377.        i% = ExitExecRestart()
  378.      ELSE
  379. '      If the RestartList list is empty, it is necessary to restart windows
  380. '      directly.  The MSSETUP program creates _MSRSTRT.EXE and _MSSETUP.BAT
  381. '      in the restart directory.  This program should be exec'd to handle
  382. '      proper MSSETUP cleanup (temp files) and restart Windows.
  383.        i% = ExitWindowsExec( GetWindowsDir() + "_MSRSTRT.EXE", "_MSSETUP.BAT" )
  384.      ENDIF
  385.  
  386. END SUB
  387.  
  388.  
  389. '**
  390. '** Purpose:
  391. '**     Appends a file name to the end of a directory path,
  392. '**     inserting a backslash character as needed.
  393. '** Arguments:
  394. '**     szDir$  - full directory path (with optional ending "\")
  395. '**     szFile$ - filename to append to directory
  396. '** Returns:
  397. '**     Resulting fully qualified path name.
  398. '*************************************************************************
  399. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  400.     IF szDir$ = "" THEN
  401.     MakePath = szFile$
  402.     ELSEIF szFile$ = "" THEN
  403.     MakePath = szDir$
  404.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  405.     MakePath = szDir$ + szFile$
  406.     ELSE
  407.     MakePath = szDir$ + "\" + szFile$
  408.     END IF
  409. END FUNCTION
  410.